package com.androidyuan.androidscreenshot_sysapi;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.androidyuan.androidscreenshot_sysapi.utils.BaseAccessibilityService;
import com.androidyuan.lib.screenshot.ScreenShotActivity;


public class MainActivity extends AppCompatActivity {
    private PackageManager mPackageManager;
    private String[] mPackages;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        BaseAccessibilityService.getInstance().init(this);
        mPackageManager = this.getPackageManager();
        mPackages = new String[]{"com.hujiang.studytool"};
        setContentView(R.layout.activity_main);
    }

    public void onClickShot(View view) {
        //1.直接启动
//        startActivity(new Intent(this, ScreenShotActivity.class));
        //2.通过service启动
        startService(new Intent(this, ScreenShotService.class));
    }

    @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
    public void goApp(View view) {
        Intent intent = mPackageManager.getLaunchIntentForPackage("com.eg.android.AlipayGphone");
        Log.i("打开", "支付宝");
        try {
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
            startActivity(intent);
        } catch (Exception e) {
            Log.i("打开", e.toString());
        }
    }
    public void goAccess(View view) {
        BaseAccessibilityService.getInstance().goAccess();
    }
}
